<?php
/**
 * 描述：会员管理中心-卖家订单列表。
 * @final
 */
final class Exec_MC_Transaction_Seller_Ordersheet_List extends Exec_MC_Master
{
    public function Get()
    {
        $do=Functions::UrlArgs('do');
        switch($do)
        {
            case 'delete':
                $this->Get_Delete();
            break;
            default :
                $this->Get_List();
        }
    }

    /**
     * 描述：显示列表
     */
    public function Get_List()
    {
        #获取数据
        $sql='select * from ordersheet where Account_Seller=? order by Datetime desc limit ?,15';
        $data=DB::PGetData($sql,array(
            Account::Session('Username')
        ));
        foreach($data['Record'] as $key=>$value)
        {
            //获取订单状态
            $data['Record'][$key]['Status']=NULL;
            $tmp=DB::PGetRows('select * from ordersheet_extend_service where OrderNumber=?',array(
                $data['Record'][$key]['OrderNumber']
            ));
            if($tmp){
                $data['Record'][$key]['Status']=$tmp[0]['Status'];
            }

            //获取订单状态描述
            $data['Record'][$key]['Status_Description_Seller']=NULL;
            $tmp=DB::PGetRows('select * from ordersheet_model_code where Code=?',array(
                $data['Record'][$key]['Status']
            ));
            if($tmp){
                $data['Record'][$key]['Status_Description_Seller']=$tmp[0]['Description_Seller'];
            }
            
            //获取买家公司名称
            $tmp=DB::PGetRows('select * from account where Username=?',array(
                $data['Record'][$key]['Account_Buyer']
            ));            
            if($tmp){                
                $data['Record'][$key]['CompanyName_Buyer']=$tmp[0]['CompanyName'];
            }

            //获取订单产品数据
            $tmp=DB::PGetRows('select * from ordersheet_detail where OrderNumber=?',array(
                $data['Record'][$key]['OrderNumber']
            ));
            $data['Record'][$key]['Supplies']=$tmp;
        }
        if(!$data){
            return;
        }

        #渲染模板
        View::Assign('Ordersheets',$data['Record']);
        View::Assign('PageMenu',PagerFactory::Create('Common')->Fetch($data,array('URL'=>'exec.php?action=mc_licence_list','IsDetail'=>TRUE)));
        $this->MasterPage_Display(View::Fetch('mc/transaction/seller/ordersheet/list.tpl'));
    }

    /**
     * 描述：删除信息。
     */
    public function Get_Delete()
    {
        #获取参数
        $id=Functions::UrlArgs('id');

        #执行操作
        DB::DeleteRowByID('licence','ID:'.$id);

        #跳转页面
        header('location:'.$_SERVER['HTTP_REFERER']);
    }

    /**
     * 描述：响应Post动作。
     */
    public function  Post()
    {
        #获取参数
        $id=Functions::FormArgs('ID');

        #执行操作
        foreach ($id as $value)
        {
            DB::DeleteRowByID('licence','ID:'.$value);
        }

        #跳转页面
        header('location:'.$_SERVER['HTTP_REFERER']);
    }
}
?>